<?php
$page->title = 'Shared? Almost';
$page->date = '2012-07-12';
?>

<h1><?= $page->title() ?></h1>
<p>If you have the good fortune to work on a team, then you must have some way to share files among
yourselves. It should go something like this:</p>
<hr class="readmore">

<h1><?= $page->title() ?></h1>

<figure class="alignright" style="width: 300px;">
  <img src="/content/blog/2012-07-12/do-not-enter.png" width="300" height="300">
  <figcaption>Even though I created a shared folder with 777 permissions, if I created a file or
  folder, it was locked for my coworker and vice versa. I dug in deep and finally found
  a solution.</figcaption>
</figure>

<p>A story of a Mac OSX user:</p>

<p>If you have the good fortune to work on a team, then you must have some way to share files among
yourselves. It should go something like this: you create a file, it's awesome, you save it to the public folder
and ask your coworker to critique it. They of course find a plethora of errors, open it (since they can see the file
thanks to read access), and begin to completely tear your work apart. And when they click save, *horrible sound*
"You do not have permission to save this file!" But it's a shared folder!!!</p>

<p>I became good at quickly finding the folder, Get Info, enter credentials, then apply to enclosed items.
This copied the top folder permissions to all folders and files within even if they were not the infringing case.
Fixed&hellip; but not a solution.</p>

<p>So today I dug in deep in search engine world with multiple forays into forum world. I discovered that this is
a common issue with Mac users. Also that 90% of these issues are solved by simply sharing folder using only
SMB (turning off AFP). I didn't like this and either way, I still had some issues.</p>

<p>I'm no <a href="http://www.urbandictionary.com/define.php?term=luddite" target="_blank">luddite</a> when it
comes to the terminal, so if you'd like some help, strap on your *nix because we're diving in.</p>

<ol>
  <li>Open up System Preferences and visit the Sharing icon</li>
  <li>Under the Options&hellip; button ensure that you are in fact sharing a folder and that you are including
  AFP protocol</li>
  <li>Include everyone that you want and grant them the permissions that you want from here</li>
  <li>Now open Terminal</li>
  <li>Find your way to the folder to be shared so that the next part is a bit less typing</li>
</ol>

<p>Now it's time for a refernce.
<a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/chmod.1.html"
target="_blank">Mac OS X Manual Page for chmod</a>. What we're going to be doing is creating a custom permissions
set using ACLs (Access Control Lists). I'm not sure if this next part was successful because of using 'sudo' or
simply because my previous flailing around the terminal set something right, so try it without first. Ok, I have a
group so that adding a user is as simple as including them in the group. We'll call it 'luddites' for
this example.</p>

<ul>
  <li><em>optional:</em> if you've attempted to create ACLs in the past and messed everything up, you can remove them all
  with one line of code: <code>chmod -N path/to/folder/or/file</code></li>
</ul>
<ol start="6">
  <li>type:<br><code>chmod -R +a "luddites allow list,search,readattr,writeattr,delete,delete_child, _<br>
  readextattr,writeextattr,readsecurity,add_file,add_subdirectory,file_inherit,directory_inherit" _<br>
  path/to/folder/or/file</code><br> (all of this on one line of course. I broke it with the _ for readability).</li>
</ol>

<p>To simply break down, this gives the group 'luddites' all the permissions and with file_inherit and directory_inherit
should also apply to all folders and files within. The '-R' flag of chmod means to go recursively, or simply to
apply this change to all folders and files within. I'm not sure if it's mandatory to work, and if the inherit works
as it should, then it may be pointless, but I didn't test that. Also, I have only tested this for files created
in the shared folder. I plan to check tomorrow if a file copied to the shared folder will be shared properly.</p>

<p>Well, I hope that this helps.</p>
